import { toSuccess, useEntityManager } from "@sker/core"
import { KsOpen } from "@sker/entities"
import { useData } from "@sker/runtime"
import { z } from "zod"

export default async () => {
    const input = z.object({
        id: z.number(),
        uuid: z.string()
    })
    const body = input.parse(useData())
    return await useEntityManager(async m => {
        const item = await m.findOne(KsOpen, { where: { id: body.id } })
        if (item) {
            await m.update(KsOpen, item.id, { status: '1', uuid: body.uuid })
        }
        return toSuccess(item)
    })
}
